#include "sd.h"

#include <stdio.h>
#include <string.h>

#define	DIRECT_BLOCK_WRITE_TEST		0

int SD_example() {
	unsigned char buffer[1024];
	
	/* open device */
	if (SD_open() == 0) {
		/* read single block */
		SD_read_block(0, buffer);
		SD_read_block(1, buffer + 512);
		
		/* read multiple blocks */
		SD_read_many_blocks(0, buffer, 2);

#if (DIRECT_BLOCK_WRITE_TEST)
		/* write single block */
		SD_write_block(384, buffer);
		SD_write_block(385, buffer + 512);
		
		/* write multiple blocks */
		SD_write_many_blocks(384, buffer, 2);
#endif		
		/* close device */
		SD_close();
	} else {
		return -1;
	}	
	return 0;
}
